import { Route, Switch, Redirect } from "react-router-dom"
import { lazy, Suspense } from "react"
import Passing from "../views/PassingAnimation/index"

const Login = lazy(() => import(/*webpackChunkName:'login'*/"@/views/Login"))
const Home = lazy(() => import(/*webpackChunkName:'home'*/"@/views/Home"))
// const NotFound = lazy(() => import(/*webpackChunkName:'notfound'*/"@/views/NotFound"))
// const Passing = lazy(()=>import("@/views/PassingAnimation"))

/**
 * 
 * @returns 这部分路由不需要进行登录验证
 */
const LoginRoute = () => {
    return (
        <Suspense fallback={<Passing></Passing>}>
            <Switch>
                <Route path="/login" component={Login} />
                {/* <Route path="*" component ={NotFound}/> */}
                <Route path="/passing" component={Passing} />
            </Switch>
        </Suspense>
    )
}

/**
 * 
 * @returns 这部分路由需要进行登录验证
 */
const AuthRoute = () => {
    return (
        <Suspense fallback={<Passing></Passing>}>
            <Switch>
                <Route path="/home" component={Home} />
                {/* //重定向路由一定要放在最后面，不要动位置 */}
                <Redirect from="/" to="/login" />
                {/* <Route path="*" component ={NotFound}/> */}
            </Switch>
        </Suspense>
    );
}


export {
    LoginRoute as default,
    AuthRoute
}